package com.insta.java.util;

import java.util.ArrayList;
import java.util.List;

import com.insta.java.dto.UserDto;
import com.insta.java.model.ILocation;
import com.insta.java.model.User;

public class UserConvert {
	
	public UserConvert(){}
	
	public static UserDto convert(User user){
		UserDto temp= new UserDto(user.getId(), user.getName(), user.getForname(), user.getLogin(), user.getPassword(), user.getIsAdmin());
		List<String> locations= new ArrayList<String>();
		for(ILocation loc: user.getLocations()){
			locations.add(loc.toString());
		}
		temp.setLocations(locations);
		return temp;
	}
	
	public static List<UserDto> convertFromListUserToListDTO(List<User> users){
		List<UserDto> list = new ArrayList<UserDto>();
		for(User user : users){
			list.add(convert(user));
		}
		return list;
	}

}
